<?php



namespace App\Model;

use Illuminate\Database\Eloquent\Model;

/**
 *  App\Models\Banner
 *  Banner模型
 */
class Banner extends Model
{
    protected $table = 'banner';

    //跳转H5链接
    const JUMP_TYPE_LINK = 1;
    //跳转用户详情
    const JUMP_TYPE_USER = 2;

    const JUMP_WX_PROGRAM = 3;

    const CHANNEL = [
        0 => '全部',
        1 => 'IOS',
        2 => '安卓'
    ];

    public function setAppChannelAttribute($channel)
    {
        $this->attributes['app_channel'] = implode(',', $channel);
    }

    /*
     * 获取所有跳转类型
     */
    static function getJumpTypes($jumpType = 0)
    {
        $ret = [
            self::JUMP_TYPE_LINK => 'H5链接',
            self::JUMP_TYPE_USER => '用户详情内页',
            self::JUMP_WX_PROGRAM => '微信小程序'
        ];
        return $jumpType > 0 ? $ret[$jumpType] : $ret;
    }
}
